package LuoGu.二分查找.高考志愿;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.PriorityQueue;

public class Main {
    public static void main(String[] args) throws IOException {
        StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        st.nextToken();
        int n = (int) st.nval;
        st.nextToken();
        int m = (int) st.nval;
        PriorityQueue<Integer> schools = new PriorityQueue<>();
        for(int i=0;i<n;i++){
            st.nextToken();
            int temp = (int) st.nval;
            schools.offer(temp);
        }
        int students [] = new int[m];
        for(int i=0;i<m;i++){
            st.nextToken();
            students[i] = (int) st.nval;
        }
        int ans = 0;
        for(int i=0;i<m;i++){
            int sc = students[i];
            boolean flag = true;
            int min = Integer.MAX_VALUE;
            while(flag){
                int a = schools.poll();
                int abs = Math.abs(a-sc);
                if(min<abs){
                    flag = false;
                }else{
                    min = abs;
                }
                schools.offer(a);
            }
            ans+=min;
        }
        System.out.print(ans);
    }
}
